package com.twu.biblioteca.util;

import com.twu.biblioteca.domain.Book;
import com.twu.biblioteca.domain.Displayable;
import com.twu.biblioteca.domain.Movie;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

public class Console {
    private final BufferedReader inputReader;
    private final PrintStream outputStream;

    public Console(InputStream inputStream, PrintStream outputStream){
        this.inputReader = new BufferedReader(new InputStreamReader(inputStream));
        this.outputStream = outputStream;
    }

    public String getUserInput(){
        String input= null;
        try {
            input = inputReader.readLine();
        } catch (IOException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return input;
    }

    public void println(final String string){
          outputStream.println(string);

     }
    public void print(final String string){
        outputStream.print(string);
    }

    /*public void printMovie(Movie movie){
        outputStream.println("Movie Name: "+movie.getName());
       outputStream.println("Movie Year: "+movie.getYear());
        outputStream.println("Movie Director: "+movie.getDirector());
        Integer rating=movie.getRating();
        if(rating==null)
            outputStream.println("Rating : N/A");
        else outputStream.println("Rating: "+String.valueOf(rating));
        outputStream.println("\n");

    }*/

    public void printList(List<Displayable> displayables){
        //int i=1;
        for(Displayable displayable:displayables){

           outputStream.println(displayable.getDisplayText());
        }
    }
    public void printMovie(Displayable displayable){
        outputStream.println(displayable.getDisplayText());
    }


   /*
    public void printBook(Book book){

        outputStream.println("Book Name: " + book.getName());
        outputStream.println("Book Author: "+book.getAuthor());
        outputStream.println("Book Publisher: "+book.getPublisherName());
        outputStream.println("Year of Publishing: "+book.getYear());
        outputStream.println("\n");

    }
   */
    /*
    public void printAllBooks(List<Book> books){
        int i=1;
        for(Book book: books){
            println(i+")");
            println(book.toString());
            i++;
        }
    } */



}




